﻿using ComponentFactory.Krypton.Toolkit;
using HLVControl.Grid;
using HLVControl.Grid.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RMAS
{
    public partial class frmQuyTrinh : Form
    {
        private static Panel objPanel = new Panel();
        EnumGUI.DanhMuc giaodien = EnumGUI.DanhMuc.KhuVuc;
        usrc_ListArea area;
        usrc_ListTable table;
        usrc_ListUnit unit;
        usrc_ListGroupMenu groupmenu;
        usrc_ListMenu menu;
        usrc_ListUnitMeterial uintmeterial;
        usrc_ListGroupMeterial GroupMeterial;
        usrc_ListMeterial meterial;
        usrc_ListWareHouse warehouse;
        usrc_ListCustommer custommer;
        usrc_ListNCC ncc;

        public frmQuyTrinh()
        {
            InitializeComponent();
        }
        public frmQuyTrinh(EnumGUI.DanhMuc giaodien)
        {
            InitializeComponent();
            this.giaodien = giaodien;
        }
        private void frmQuyTrinh_Load(object sender, EventArgs e)
        {
            area = new usrc_ListArea();
            area.Dock = DockStyle.Fill;
            this.SplitContainer.Panel2.Controls.Add(area);
            area.Show();
            getTableWaitting();
           // ChonUI(giaodien);
        }

        private void ChonUI(EnumGUI.DanhMuc _giaodien)
        {
            this.SplitContainer.Panel2.Controls.Clear();
            switch (_giaodien)
            {
                case EnumGUI.DanhMuc.KhuVuc:
                    area = new usrc_ListArea();
                    area.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(area);
                    area.Show();
                    break;
                case EnumGUI.DanhMuc.Ban:
                    table = new usrc_ListTable();
                    table.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(table);
                    table.Show();
                    break;
                case EnumGUI.DanhMuc.NhomThucDon:
                    groupmenu = new usrc_ListGroupMenu();
                    groupmenu.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(groupmenu);
                    groupmenu.Show();
                    break;
                case EnumGUI.DanhMuc.ThucDon:
                    menu = new usrc_ListMenu();
                    menu.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(menu);
                    menu.Show();
                    break;
                case EnumGUI.DanhMuc.DonViSanPham:
                    unit = new usrc_ListUnit();
                    unit.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(unit);
                    unit.Show();
                    break;
                case EnumGUI.DanhMuc.KhoHangSanPham:
                    warehouse = new usrc_ListWareHouse();
                    warehouse.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(warehouse);
                    warehouse.Show();
                    break;
                case EnumGUI.DanhMuc.NhomNVL:
                    GroupMeterial = new usrc_ListGroupMeterial();
                    GroupMeterial.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(GroupMeterial);
                    GroupMeterial.Show();
                    break;
                case EnumGUI.DanhMuc.NVL:
                    meterial = new usrc_ListMeterial();
                    meterial.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(meterial);
                    meterial.Show();
                    break;
                case EnumGUI.DanhMuc.DonViNVL:
                    uintmeterial = new usrc_ListUnitMeterial();
                    uintmeterial.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(uintmeterial);
                    uintmeterial.Show();
                    break;
                case EnumGUI.DanhMuc.KhoHangNVL:

                    break;
                case EnumGUI.DanhMuc.NhaCungCap:
                    ncc = new usrc_ListNCC();
                    ncc.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(ncc);
                    ncc.Show();
                    break;
                case EnumGUI.DanhMuc.KhachHang:
                    custommer = new usrc_ListCustommer();
                    custommer.Dock = DockStyle.Fill;
                    this.SplitContainer.Panel2.Controls.Add(custommer);
                    custommer.Show();
                    break;
                case EnumGUI.DanhMuc.NhanVien:

                    break;
                case EnumGUI.DanhMuc.BangChamCong:

                    break;
            }
            getTableWaitting();
        }
        private void button_Click(object sender, EventArgs e)
        {
            KryptonCheckButton btn = (KryptonCheckButton)sender;
            string nameform = btn.Tag.ToString();
            switch (nameform)
            {
                case "khuvuc":
                    ChonUI(EnumGUI.DanhMuc.KhuVuc);
                    break;
                case "ban":
                    ChonUI(EnumGUI.DanhMuc.Ban);
                    break;
                case "nhomthucdon":
                    ChonUI(EnumGUI.DanhMuc.NhomThucDon);
                    break;
                case "thucdon":
                    ChonUI(EnumGUI.DanhMuc.ThucDon);
                    break;
                case "donvisp":
                    ChonUI(EnumGUI.DanhMuc.DonViSanPham);
                    break;
                case "khohangsp":
                    ChonUI(EnumGUI.DanhMuc.KhoHangSanPham);
                    break;
                case "nhomnvl":
                    ChonUI(EnumGUI.DanhMuc.NhomNVL);
                    break;
                case "nguyenvatlieu":
                    ChonUI(EnumGUI.DanhMuc.NVL);
                    break;
                case "donvinvl":
                    ChonUI(EnumGUI.DanhMuc.DonViNVL);
                    break;
                case "khohangnvl":
                    ChonUI(EnumGUI.DanhMuc.KhoHangNVL);
                    break;
                case "nhacungcap":
                    ChonUI(EnumGUI.DanhMuc.NhaCungCap);
                    break;
                case "khachhang":
                    ChonUI(EnumGUI.DanhMuc.KhachHang);
                    break;
                case "nhanvien":
                    ChonUI(EnumGUI.DanhMuc.NhanVien);
                    break;
                case "bangchamcong":
                    ChonUI(EnumGUI.DanhMuc.BangChamCong);
                    break;
            }

        }
        public static void getTableWaitting()
        {
            objPanel.Controls.Clear();
        }
        private void CreateColumn(TreeListView treeview, StringAlignment AlignCellHorizontal, bool AllowEdit, bool AllowResize, int Width, string Name, string Text, bool Visible)
        {
            try
            {
                TreeListColumn col = new TreeListColumn();
                col.AlignCellHorizontal = AlignCellHorizontal;
                col.AllowEdit = AllowEdit;
                col.AllowResize = AllowResize;
                col.MinWidth = (int)Math.Round((Decimal)Width / 2, 0);
                col.Name = Name;
                col.Text = Text;
                col.Visible = Visible;
                col.Width = Width;
     
                treeview.Columns.Add(col);
            }
            catch { }
        }
    }
}
